home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / system / bbs / pub_acc.taz / pub_acc / keirsey.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-29  |  16.0 KB  |  629 lines

  1. #include <stdio.h>
  2. #include <ctype.h>
  3.  
  4. #define CLASSES 4
  5.  
  6. #define EI    0
  7. #define SN    1
  8. #define TF    2
  9. #define JP    3
  10.  
  11. int a[CLASSES], b[CLASSES];    /* numbers of a and b answers of each type */
  12.  
  13. char type[CLASSES+1];        /* person's type string */
  14.  
  15. char ac[CLASSES+1] = "ESTJ";
  16. char bc[CLASSES+1] = "INFP";
  17.  
  18. char *an[CLASSES] = {"Extravert", "Sensing", "Thinking", "Judging"};
  19. char *bn[CLASSES] = {"Introvert", "Intuitive", "Feeling", "Perceptive"};
  20.  
  21. struct qs {
  22.     char *q;        /* question text (NULL marks end of list) */
  23.     char *a;        /* (a) answer text */
  24.     char *b;    /* (b) answer text */
  25.     int t;        /* question type:  one of EI, SN, TF, or JP */
  26.     } questions[] = {
  27.     /* 1-7 */
  28.     { "At a party do you",
  29.       "interact with many, including strangers",
  30.       "interact with a few, known to you",
  31.       EI },
  32.     { "Are you more",
  33.       "realistic than speculative",
  34.       "speculative than realistic",
  35.       SN },
  36.     { "Is it worse to",
  37.       "have your \042head in the clouds\042",
  38.       "be \042in a rut\042",
  39.       SN },
  40.     { "Are you more impressed by",
  41.       "principles",
  42.       "emotions",
  43.       TF },
  44.     { "Are you more drawn toward the",
  45.       "convincing",
  46.       "touching",
  47.       TF },
  48.     { "Do you prefer to work",
  49.       "to deadlines",
  50.       "just \042whenever\042",
  51.       JP },
  52.     { "Do you tend to choose",
  53.       "rather carefully",
  54.       "somewhat impulsively",
  55.       JP },
  56.  
  57.     /* 8 */
  58.     { "At parties do you",
  59.       "stay late, with increasing energy",
  60.       "leave early, with decreased energy",
  61.       EI },
  62.     /* 9 */
  63.     { "Are you more attracted to",
  64.       "sensible people",
  65.       "imaginative people",
  66.       SN },
  67.     /* 10 */
  68.     { "Are you more interested in",
  69.       "what is actual",
  70.       "what is possible",
  71.       SN },
  72.     /* 11 */
  73.     { "In judging others are you more swayed by",
  74.       "laws than circumstances",
  75.       "circumstances than laws",
  76.       TF },
  77.     /* 12 */
  78.     { "In approaching other is your inclination to be somewhat",
  79.       "objective",
  80.       "personal",
  81.       TF },
  82.     /* 13 */
  83.     { "Are you more",
  84.       "punctual",
  85.       "leisurely",
  86.       JP },
  87.     /* 14 */
  88.     { "Does it bother you more to have things",
  89.       "incomplete",
  90.       "completed",
  91.       JP },
  92.  
  93.     /* 15-21 */
  94.     { "In your social groups do you",
  95.       "keep abreast of other's happenings",
  96.       "get behind on the news",
  97.       EI },
  98.     { "In doing ordinary things are you more likely to",
  99.       "do it the usual way",
  100.       "do it your own way",
  101.       SN },
  102.     { "Writers should",
  103.       "\042say what they mean and mean what they say\042",
  104.       "express things more by use of analogy",
  105.       SN },
  106.     { "Which appeals to you more",
  107.       "consistency of thought",
  108.       "harmonious human relations",
  109.       TF },
  110.     { "Are you more comfortable in making",
  111.       "logical judgements",
  112.       "value judgements",
  113.       TF },
  114.     { "Do you want things",
  115.       "settled and decided",
  116.       "unsettled and undecided",
  117.       JP },
  118.     { "Would you say you are more",
  119.       "serious and determined",
  120.       "easy going",
  121.       JP },
  122.  
  123.     /* 22-28 */
  124.     { "In phoning do you",
  125.       "rarely question that it will all be said",
  126.       "rehearse what you'll say",
  127.       EI },
  128.     { "Facts",
  129.       "\042speak for themselves\042",
  130.       "illustrate principles",
  131.       SN },
  132.     { "Are visionaries",
  133.       "some what annoying",
  134.       "rather fascinating",
  135.       SN },
  136.     { "Are you more often",
  137.       "a cool-headed person",
  138.       "a warm-hearted person",
  139.       TF },
  140.     { "Is it worse to be",
  141.       "unjust",
  142.       "merciless",
  143.       TF },
  144.     { "Should one usually let events occur",
  145.       "by careful selection",
  146.       "randomly and by chance",
  147.       JP },
  148.     { "Do you feel better about",
  149.       "having purchased",
  150.       "having the option to buy",
  151.       JP },
  152.  
  153.     /* 29-35 */
  154.     { "In company do you",
  155.       "initiate conversation",
  156.       "wait to be approached",
  157.       EI },
  158.     { "Common sense is",
  159.       "rarely questionable",
  160.       "frequently questionable",
  161.       SN },
  162.     { "Children often do not",
  163.       "make themselves useful enough",
  164.       "exercise their fantasy enough",
  165.       SN },
  166.     { "In making decisions do you feel more comfortable with",
  167.       "standards",
  168.       "feelings",
  169.       TF },
  170.     { "Are you more",
  171.       "firm than gentle",
  172.       "gentle than firm",
  173.       TF },
  174.     { "Which is more admirable:",
  175.       "the ability to organize and be methodical",
  176.       "the ability to adapt and make do",
  177.       JP },
  178.     { "Do you put more value on the",
  179.       "definite",
  180.       "open-ended",
  181.       JP },
  182.  
  183.     /* 36-42 */
  184.     { "Does new and non-routine interaction with others",
  185.       "stimulate and energize you",
  186.       "tax your reserves",
  187.       EI },
  188.     { "Are you more frequently",
  189.       "a practical sort of person",
  190.       "a fanciful sort of person",
  191.       SN },
  192.     { "Are you more likely to",
  193.       "see how other are useful",
  194.       "see how others see",
  195.       SN },
  196.     { "Which is more satisfying:",
  197.       "to discuss an issue thoroughly",
  198.       "to arrive at agreement on an issue",
  199.       TF },
  200.     { "Which rules you more:",
  201.       "your head",
  202.       "your heart",
  203.       TF },
  204.     { "Are you more comfortable with work that is",
  205.       "contracted",
  206.       "done on a casual basis",
  207.       JP },
  208.     { "Do you tend to look for",
  209.       "the orderly",
  210.       "whatever turns up",
  211.       JP },
  212.  
  213.     /* 43-49 */
  214.     { "Do you prefer",
  215.       "many friends with brief contact",
  216.       "a few friends with more lengthy contact",
  217.       EI },
  218.     { "Do you go more by",
  219.       "facts",
  220.       "principles",
  221.       SN },
  222.     { "Are you more interested in",
  223.       "production and distribution",
  224.       "design and research",
  225.       SN },
  226.     { "Which is more of a compliment",
  227.       "\042There is a very logical person\042",
  228.       "\042There is a very sentimental person\042",
  229.       TF },
  230.     { "Do you value in yourself more that you are",
  231.       "unwavering",
  232.       "devoted",
  233.       TF },
  234.     { "Do you more often prefer the",
  235.       "final and unalterable statement",
  236.       "tentative and preliminary statement",
  237.       JP },
  238.     { "Are you more comfortable",
  239.       "after a decision",
  240.       "before a decision",
  241.       JP },
  242.  
  243.     /* 50-56 */
  244.     { "Do you",
  245.       "speak easily and at length with strangers",
  246.       "find little to say to strangers",
  247.       EI },
  248.     { "Are you more likely to trust your",
  249.       "experience",
  250.       "hunch",
  251.       SN },
  252.     { "Do you feel",
  253.       "more practical than ingenious",
  254.       "more ingenious than practical",
  255.       SN },
  256.     { "Which person is more to be complimented:  one of",
  257.       "clear reason",
  258.       "strong feeling",
  259.       TF },
  260.     { "Are you inclined to be",
  261.       "fair-minded",
  262.       "sympathetic",
  263.       TF },
  264.     { "Is it preferable mostly to",
  265.       "make sure things are arranged",
  266.       "just let things happen",
  267.       JP },
  268.     { "In relationships should most things be",
  269.       "renegotiable",
  270.       "random and circumstantial",
  271.       JP },
  272.  
  273.     /* 57-63 */
  274.     { "When a phone rings do you",
  275.       "hasten to get to it first",
  276.       "hope someone else will answer",
  277.       EI },
  278.     { "Do you prize more in yourself",
  279.       "a strong sense of reality",
  280.       "a vivid imagination",
  281.       SN },
  282.     { "Are you drawn more to",
  283.       "fundamentals",
  284.       "overtones",
  285.       SN },
  286.     { "Which seems the greater error:",
  287.       "to be too passionate",
  288.       "to be too objective",
  289.       TF },
  290.     { "Do you see yourself as basically",
  291.       "hard-hearted",
  292.       "soft-hearted",
  293.       TF },
  294.     { "Which situation appeals to you more:",
  295.       "the structured and scheduled",
  296.       "the unstructured and unscheduled",
  297.       JP },
  298.     { "Are you a person that is more",
  299.       "routinized than whimsical",
  300.       "whimsical than routinized",
  301.       JP },
  302.  
  303.     /* 64-70 */
  304.     { "Are you more inclined to be",
  305.       "easy to approach",
  306.       "somewhat reserved",
  307.       EI },
  308.     { "In writings do you prefer",
  309.       "the more literal",
  310.       "the more figurative",
  311.       SN },
  312.     { "Is it harder for you to",
  313.       "identify with others",
  314.       "utilize others",
  315.       SN },
  316.     { "Which do you wish more for yourself:",
  317.       "clarity of reason",
  318.       "strength of compassion",
  319.       TF },
  320.     { "Which is the greater fault:",
  321.       "being indiscriminate",
  322.       "being critical",
  323.       TF },
  324.     { "Do you prefer the",
  325.       "planned event",
  326.       "unplanned event",
  327.       JP },
  328.     { "Do you tend to be more",
  329.       "deliberate than spontaneous",
  330.       "spontaneous than deliberate",
  331.       JP },
  332.  
  333.     {NULL,NULL,NULL,0}};
  334.  
  335.  
  336. struct ds {
  337.     char *t;    /* type string */
  338.     char *d;    /* description */
  339.     } descriptions[] = {
  340.     { "ISTJ",
  341. " Serious, quiet, earn success by concentration and thoroughness.  Practical,\n\
  342.  orderly, matter-of-fact, logical, realistic, and dependable.  See to it that\n\
  343.  everything is well organized.  Take responsiblity.  Make up their own minds\n\
  344.  as to what should be accomplished and work toward it steadily, regardless\n\
  345.  or protests or distractions.\n"},
  346.     { "ISFJ",
  347. " Quiet, friendly, responsible, and conscientious.  Work devotedly to meet\n\
  348.  their obligations.  Lend stability to any project or group.  Thorough,\n\
  349.  painstaking, accurate.  Their interests are usually not technical.  Can be\n\
  350.  patient with necessary details.  Loyal, considerate, perceptive, concerned\n\
  351.  with how other people feel.\n"},
  352.     { "INFJ",
  353. " Succeed by perseverance, originality, and desire to do whatever is needed\n\
  354.  or wanted.  Put their best efforts into their work.  Quietly forceful,\n\
  355.  conscientious, concerned for others.  Respected for their firm principles.\n\
  356.  Likely to be honored and followed for their clear convictions as to how to\n\
  357.  best serve the the common good.\n"},
  358.     { "INTJ",
  359. " Usually have original minds and great drive for their own ideas and\n\
  360.  purposes.  In fields that appeal to them, they have a fine power to organize\n\
  361.  a job and carry it through with or without help.  Skeptical, critical,\n\
  362.  independent, determined, sometimes stubborn.  Must learn to yield less\n\
  363.  important points in order to win the most important.\n"},
  364.     { "ISTP",
  365. " Cool onlookers--quiet, reserved, observing and analyzing life with detached\n\
  366.  curiosity and unexpected flashes of original humor.  Usually interested in\n\
  367.  cause and effect, how and why mechanical things work, and in organizing\n\
  368.  facts using logical principles.\n"},
  369.     { "ISFP",
  370. " Retiring, quietly friendly, sensitive, kind, modest about their abilities.\n\
  371.  Shun disagreements, do not force their opinions or values on others.  Usually\n\
  372.  do not care to lead but are often loyal followers.  Often relaxed about\n\
  373.  getting things done, because they enjoy the present moment and do not want\n\
  374.  to spoil it by undue haste or exertion.\n"},
  375.     { "INFP",
  376. " Full of enthusiasms and loyalties, but seldom talk of these until they know\n\
  377.  you well.  Care about learning, ideas, language, and independent projects\n\
  378.  of their own.  Tend to undertake too much, then somehow get it done.\n\
  379.  Friendly, but often too absorbed in what they are doing to be sociable.\n\
  380.  Little concerned with possessions or physical surroundings.\n"},
  381.     { "INTP",
  382. " Quiet and reserved.  Especially enjoy theoretical or scientific pursuits.\n\
  383.  Like solving problems with logic and analysis.  Usually interested mainly in\n\
  384.  ideas, with little liking for parties or small talk.  Tend to have sharply\n\
  385.  defined interests.  Need careers where some strong interest can be used and\n\
  386.  useful.\n"},
  387.     { "ESTP",
  388. " Good at on-the-spot problem solving.  Do not worry, enjoy whatever comes\n\
  389.  along.  Tend to like mechanical things and sports, with friends on the side.\n\
  390.  Adaptable, tolerant, generally conservative in values.  Dislike long\n\
  391.  explanations.  Are best with real things that can be worked, handled, take\n\
  392.  apart, or put together.\n"},
  393.     { "ESFP",
  394. " Outgoing, easygoing, accepting, friendly, enjoy everything and make things\n\
  395.  more fun for others by their enjoyment.  Like sports and making things\n\
  396.  happen.  Know what's going on and join in eagerly.  Find remembering facts\n\
  397.  easier than mastering theories.  Are best in situations that need sound\n\
  398.  common sense and practical ability with people as well as with things.\n"},
  399.     { "ENFP",
  400. " Warmly enthusiastic, high-spirited, ingenious, imaginative.  Able to do\n\
  401.  almost anything that interests them.  Quick with a solution for any\n\
  402.  difficulty and ready to help anyone with a problem.  Often rely on their\n\
  403.  ability to improvise instead of preparing in advance.  Can usually find\n\
  404.  compelling reasons for whatever they want.\n"},
  405.     { "ENTP",
  406. " Quick, ingenious, good at many things.  Stimulating company, alert and\n\
  407.  outspoken.  May argue for fun on either side of a question.  Resourceful in\n\
  408.  solving new and challenging problems, but may neglect routine assignments.\n\
  409.  Apt to turn to one new interest after another.  Skillful in finding logical\n\
  410.  reasons for what they want.\n"},
  411.     { "ESTJ",
  412. " Practical, realistic, matter-of-fact, with a natural head for business or\n\
  413.  mechanics.  Not interested in subjects they see no use for, but can apply\n\
  414.  themselves when necessary.  Like to organize and run activities.  May make\n\
  415.  good administrators, especially if they remember to consider others'\n\
  416.  feelings and points of view.\n"},
  417.     { "ESFJ",
  418. " Warm-hearted, talkative, popular, conscientious, born cooperators, active\n\
  419.  committee members.  Need harmony and may be good at creating it.  Always\n\
  420.  doing something nice for someone.  Work best with encouragement and praise.\n\
  421.  Main interest is in things that directly and visibly affect people's lives.\n"},
  422.     { "ENFJ",
  423. " Responsive and responsible. Generally feel real concern for what others\n\
  424.  think or want, and try to handle things with due regard for the other\n\
  425.  person's feelings.  Can present a proposal or lead a group discussion with\n\
  426.  ease and tact.  Sociable, popular, sympathetic.  Responsive to praise and\n\
  427.  criticism.\n"},
  428.     { "ENTJ",
  429. " Hearty, frank, decisive, leaders in activities.  Usually good in anything\n\
  430.  that requires reasoning and intelligent talk, such as public speaking.  Are\n\
  431.  usually well informed and enjoy adding to their fund of knowledge.  May\n\
  432.  sometimes appear more positive and confident than their experience in an\n\
  433.  area warrants.\n"},
  434.     {NULL,NULL}};
  435.  
  436. int qn=0;
  437. char *progname;
  438.  
  439. char qflag=0;
  440. char desflag=0;
  441.  
  442. main(argc,argv)
  443. int argc;
  444. char **argv;
  445. {
  446. int i,j;
  447. struct qs *qp;
  448.  
  449.     progname = argv[0];
  450.  
  451.     for (i=1; i<argc; i++)
  452.     {
  453.         if (argv[i][0] == '-')
  454.             for (j=1; argv[i][j]; j++)
  455.                 switch (argv[i][j])
  456.                 {
  457.                 case 'q':
  458.                     qflag = 1;
  459.                     break;
  460.                 default:
  461.                     usage();
  462.                 }
  463.         else if (check_string(argv[i]) && !desflag)
  464.         {
  465.             desflag = 1;
  466.             strcpy(type,argv[i]);
  467.         }
  468.         else
  469.             usage();
  470.     }
  471.  
  472.     /* Just list the questions */
  473.     if (qflag)
  474.     {
  475.         for (qp = questions,i=1; qp->q; qp++,i++)
  476.         {
  477.             printq(qp,i);
  478.             putchar('\n');
  479.         }
  480.         exit(0);
  481.     }
  482.  
  483.     if (!desflag)
  484.     {
  485.         printf("The Keirsey Temperament Sorter\n\n");
  486.         printf("There are 70 questions.  Give the answer (a or b) that best describes\n");
  487.         printf("your normal behavior.  The results of this test will not be recorded.\n\n");
  488.         askall();
  489.         printf("\nScoring:\n");
  490.         class_string();
  491.     }
  492.     print_class();
  493.  
  494.     exit(0);
  495. }
  496.  
  497. usage()
  498. {
  499.     fprintf(stderr,"usage: %s [-q] [(E|I|?)(S|N|?)(T|F|?)(J|P|?)]\n",
  500.         progname);
  501.     exit(1);
  502. }
  503.  
  504. printq(qp,qn)
  505. struct qs *qp;
  506. int qn;
  507. {
  508.     printf("%2d.  %s\n",qn,qp->q);
  509.     printf("      (a) %s\n",qp->a);
  510.     printf("      (b) %s\n",qp->b);
  511. }
  512.  
  513. answera(qp,qn)
  514. struct qs *qp;
  515. int qn;
  516. {
  517. int ch, ans;
  518.  
  519.     for (;;)
  520.     {
  521.         printq(qp,qn);
  522.         printf("? ");
  523.         while ((ch=getchar()) == ' ' || ch == '\t' || ch == '(' )
  524.             ;
  525.         if (ch == EOF) exit(1);
  526.         ans = ch;
  527.         if (ch != '\n')
  528.         {
  529.             while ((ch=getchar()) != '\n')
  530.                 if (ch == EOF) exit(1);
  531.         }
  532.         if (ans == 'a' || ans == 'A') return(1);
  533.         if (ans == 'b' || ans == 'B') return(0);
  534.         printf("Please answer A or B, whichever is most appropriate.\n\n");
  535.     }
  536. }
  537.  
  538. askall()
  539. {
  540. struct qs *qp;
  541. int qn;
  542. int i;
  543.  
  544.     for (i=0; i<CLASSES; i++)
  545.         a[i] = b[i] = 0;
  546.  
  547.     for (qp = questions,qn=1; qp->q; qp++,qn++)
  548.     {
  549.         if (answera(qp,qn))
  550.             a[qp->t]++;
  551.         else
  552.             b[qp->t]++;
  553.     }
  554. }
  555.  
  556. class_string()
  557. {
  558. int i;
  559.  
  560.     type[CLASSES] = 0;
  561.  
  562.     for (i=0; i<CLASSES; i++)
  563.     {
  564.         if (a[i] > b[i])
  565.             type[i] = ac[i];
  566.         else if (a[i] < b[i])
  567.             type[i] = bc[i];
  568.         else 
  569.             type[i] = '?';
  570.  
  571.         printf("  %c  %3d%% %-10s   %3d%% %-10s\n",
  572.             type[i],
  573.             100*a[i]/(a[i]+b[i]), an[i],
  574.             100*b[i]/(a[i]+b[i]), bn[i]);
  575.     }
  576. }
  577.     
  578. int type_match(t)
  579. char *t;
  580. {
  581. int i;
  582.     for (i=0; i<CLASSES;i++)
  583.         if (type[i] != '?' && type[i] != t[i])
  584.             return(0);
  585.     return(1);
  586. }
  587.  
  588. print_class()
  589. {
  590. struct ds *dp;
  591. int flag=0;
  592.  
  593.     if (!desflag)
  594.     {
  595.        if (strchr(type,'?'))
  596.           printf("\nYou fall on the borderline between several classes:\n");
  597.        else
  598.           printf("\nYour type is:\n");
  599.     }
  600.     
  601.     for (dp=descriptions; dp->t; dp++)
  602.         if (type_match(dp->t))
  603.         {
  604.         if (!desflag && ((flag++)%2)) hrtc();
  605.         printf("\n%s\n\n%s",dp->t,dp->d);
  606.         }
  607. }
  608.  
  609. check_string(t)
  610. char *t;
  611. {
  612. int i;
  613.     for (i=0; i<CLASSES;i++)
  614.         if (islower(t[i])) t[i] = toupper(t[i]);
  615.         if (t[i] != '?' && t[i] != ac[i] && t[i] != bc[i])
  616.             return(0);
  617.  
  618.     return(t[CLASSES] == '\0');
  619. }
  620.  
  621. hrtc()
  622. {
  623. int ch;
  624.     printf("\nHit <return> to continue ");
  625.     while ((ch=getchar()) != '\n' && ch != EOF)
  626.         ;
  627. }
  628.  
  629.